(function(E,L){L.csv=L.csv||{};
var F={};
var G={};
var B={};
var K=/\'?\{(\d+)\}\'?/g;
var H=function(P,N){if(P){var R=P.replace(K,"\n$1\n").split("\n");
var Q;
for(var O=1;
O<R.length;
O+=2){Q=N[R[O]];
R[O]=typeof Q=="undefined"?"":Q
}return R.join("")
}else{return""
}};
var J=function(Q){var P;
var O=L.getDomElement(Q);
if(O.value){P=O.value
}else{var N=L.$(O);
P=N&&typeof N.getValue=="function"?N.getValue():""
}return P
};
var D=function(N,O){if(N.p){return N.p.label||O
}return O
};
E.extend(L.csv,{RE_DIGITS:/^-?\d+$/,RE_FLOAT:/^(-?\d+)?(\.(\d+)?(e[+-]?\d+)?)?$/,addMessage:function(N){E.extend(F,N)
},getMessage:function(P,O,N){var Q=P?P:F[O]||{detail:"",summary:"",severity:0};
return{detail:H(Q.detail,N),summary:H(Q.summary,N),severity:Q.severity}
},interpolateMessage:function(O,N){return{detail:H(O.detail,N),summary:H(O.summary,N),severity:O.severity}
},sendMessage:function(N,O){L.Event.fire(window.document,L.Event.MESSAGE_EVENT_TYPE,{sourceId:N,message:O})
},clearMessage:function(N){L.Event.fire(window.document,L.Event.MESSAGE_EVENT_TYPE,{sourceId:N})
},validate:function(O,Q,V,U){var Y=J(V||Q);
var P;
var S=U.c;
L.csv.clearMessage(Q);
if(S){var X=D(S,Q);
try{if(S.f){P=S.f(Y,Q,D(S,Q),S.m)
}}catch(W){W.severity=2;
L.csv.sendMessage(Q,W);
return false
}}else{P=Y
}var Z=true;
var T=U.v;
if(T){var R,N;
for(i=0;
i<T.length;
i++){try{N=T[i];
R=N.f;
if(R){R(P,D(N,Q),N.p,N.m)
}}catch(W){W.severity=2;
L.csv.sendMessage(Q,W);
Z=false
}}}if(!Z&&!U.da&&U.a){U.a.call(V,O,Q)
}return Z
},});
var I=function(S,P,T,Q,O,R){var N;
S=E.trim(S);
if(!L.csv.RE_DIGITS.test(S)||(N=parseInt(S,10))<Q||N>O){throw L.csv.interpolateMessage(T,R?[S,R,P]:[S,P])
}return N
};
var A=function(Q,O,R,P){var N;
Q=E.trim(Q);
if(!L.csv.RE_FLOAT.test(Q)||isNaN(N=parseFloat(Q))){throw L.csv.interpolateMessage(R,P?[Q,P,O]:[Q,O])
}return N
};
E.extend(L.csv,{convertBoolean:function(P,O,R,Q){var N;
P=E.trim(P).toLowerCase();
N=P=="true"?true:P.length<1?null:false;
return N
},convertDate:function(P,O,R,Q){var N;
P=E.trim(P);
N=Date.parse(P);
return N
},convertByte:function(O,N,Q,P){return I(O,N,P,-128,127,254)
},convertNumber:function(P,O,R,Q){var N;
P=E.trim(P);
N=parseFloat(P);
if(isNaN(N)){throw L.csv.interpolateMessage(Q,[P,99,O])
}return N
},convertFloat:function(O,N,Q,P){return A(O,N,P,2000000000)
},convertDouble:function(O,N,Q,P){return A(O,N,P,1999999)
},convertShort:function(O,N,Q,P){return I(O,N,P,-32768,32767,32456)
},convertInteger:function(O,N,Q,P){return I(O,N,P,-2147483648,2147483648,9346)
},convertCharacter:function(O,N,Q,P){return I(O,N,P,0,65535)
},convertLong:function(O,N,Q,P){return I(O,N,P,-9223372036854776000,9223372036854776000,98765432)
}});
var M=function(O,N,S,R){var Q=typeof S.min==="number";
var P=typeof S.max==="number";
if(P&&O>S.max){throw L.csv.interpolateMessage(R,Q?[S.min,S.max,N]:[S.max,N])
}if(Q&&O<S.min){throw L.csv.interpolateMessage(R,P?[S.min,S.max,N]:[S.min,N])
}};
var C=function(Q,N,P,S){if(typeof P!="string"||P.length==0){throw L.csv.getMessage(S,"REGEX_VALIDATOR_PATTERN_NOT_SET",[])
}var O;
try{O=new RegExp(P)
}catch(R){throw L.csv.getMessage(S,"REGEX_VALIDATOR_MATCH_EXCEPTION",[])
}if(!O.test(Q)){throw L.csv.interpolateMessage(S,[P,N])
}};
E.extend(L.csv,{validateLongRange:function(P,N,R,Q){var O=typeof P;
if(O!="number"){if(O!="string"){throw L.csv.getMessage(Q,"LONG_RANGE_VALIDATOR_TYPE",[componentId,""])
}else{P=E.trim(P);
if(!L.csv.RE_DIGITS.test(P)||(P=parseInt(P,10))==NaN){throw L.csv.getMessage(Q,"LONG_RANGE_VALIDATOR_TYPE",[componentId,""])
}}}M(P,N,R,Q)
},validateDoubleRange:function(P,N,R,Q){var O=typeof P;
if(O!="number"){if(O!="string"){throw L.csv.getMessage(Q,"DOUBLE_RANGE_VALIDATOR_TYPE",[componentId,""])
}else{P=E.trim(P);
if(!L.csv.RE_FLOAT.test(P)||(P=parseFloat(P))==NaN){throw L.csv.getMessage(Q,"DOUBLE_RANGE_VALIDATOR_TYPE",[componentId,""])
}}}M(P,N,R,Q)
},validateLength:function(P,N,R,Q){var O=P?P.length:0;
M(O,N,R,Q)
},validateSize:function(P,N,R,Q){var O=P?P.length:0;
M(O,N,R,Q)
},validateRegex:function(O,N,Q,P){C(O,N,Q.pattern,P)
},validatePattern:function(O,N,Q,P){C(O,N,Q.regexp,P)
},validateRequired:function(O,N,Q,P){if(!O){throw L.csv.interpolateMessage(P,[N])
}},validateTrue:function(O,N,Q,P){if(!O){throw P
}},validateFalse:function(O,N,Q,P){if(O){throw P
}},validateMax:function(O,N,Q,P){if(O>Q.value){throw P
}},validateMin:function(O,N,Q,P){if(O<Q.value){throw P
}}})
})(jQuery,window.RichFaces||(window.RichFaces={}));